/*
 * Copyright 2013 Glassy Cinema.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package hu.glassy.web.component.common;

import hu.glassy.web.panel.common.CustomPanel;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.model.IModel;

/**
 * Ajax link felirattal
 *
 * @author molnar.alexander@sonrisa.hu
 */
public abstract class CustomAjaxLinkPanel extends CustomPanel<String>
{

  private static final long serialVersionUID = -7694572319957371543L;

  /**
   * Konstruktor
   *
   * @param id
   * @param labelModel
   */
  public CustomAjaxLinkPanel(final String id, final IModel<String> labelModel)
  {
    super(id);

    final CustomAjaxLink link = new CustomAjaxLink("link")
    {
      private static final long serialVersionUID = 1L;

      @Override
      public void onClick(final AjaxRequestTarget target)
      {
        onLinkClick(target);
      }
    };
    link.add(new AttributeModifier("class", getCssClass()));
    add(link);

    link.add(new Label("label", labelModel));
  }

  public String getCssClass()
  {
    return "";
  }

  abstract public void onLinkClick(AjaxRequestTarget target);
}
